%Declare the symbolic variables (syms)
syms lb1Val sVal phiVal lb0Val u0Val 

f=lb1Val - ((1-sVal*phiVal*(1-xib))*lb0Val+phiVal*xib*u0Val); 
%Take symbolic derivatives
dd1 = diff(f,lb1Val);
dd2 = diff(f,sVal);
dd3 = diff(f,phiVal);
dd4 = diff(f,lb0Val);
dd5 = diff(f,u0Val);
%dd6 = diff(f,deltaVal); %Leonardo modified it 20/01/2021
%dd7 = diff(f,xibVal);

%Evaluates symbolic derivatives
lb1Val=lb;   %linearization
sVal=s;  %linearization
phiVal=phi0;   %linearization     %Renato modified 21/12
lb0Val=lb; %linearization
u0Val=U0star; %linearization
% deltaVal=delta; %linearization %Leonardo modified it 20/01/2021
%xibVal=xib; %linearization

%Substitute the symbolic values into the equations for the partial derivatives
D1=subs(dd1);
D2=subs(dd2);
D3=subs(dd3);
D4=subs(dd4);
D5=subs(dd5);
%D6=subs(dd6); %Leonardo modified it 20/01/2021
%D7=subs(dd7);

% Transform symbolic into numbers (with double precision)
d1=double(D1);
d2=double(D2);
d3=double(D3);
d4=double(D4);
d5=double(D5);
%d6=double(D6);%Leonardo modified it 20/01/2021
%d7=double(D7);

ACont(5,lbLog)        = d1;
ACont(5,shksLog)      = d2;
ACont(5,phiLog)       = d3;
% ALag(5,lbLog)       = -d4;          %ALag(15,QLog)       = -d4;
ACont(5,lb0Log)       = d4;          %Modified by Leonardo 1/20/2021
ACont(5,uzeroLog)     = d5; 
% ACont(5,shkdeltaLog) = d6; %Leonardo modified it 20/01/2021
%ACont(5,shkxibLog) = d7; 

